package scantask.client.presentationLayer;

import gov.nasa.worldwind.WorldWindow;
import gov.nasa.worldwind.layers.AirspaceLayer;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.CompoundBorder;
import javax.swing.border.TitledBorder;

public class UpperPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	// The world window of NASA.
	final private WorldWindow _wwd;
	
	// Show/Hide panel.
	static private ShowHidePanel _showHidePanel;
	
	static private LoginLogo _logoPanel;
	
	// The tabs.
	static final private JTabbedPane _tabs = new JTabbedPane(JTabbedPane.TOP);
	
	public UpperPanel(WorldWindow wwd)
    {
        super(new BorderLayout());
        this._wwd = wwd;
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        this.setPreferredSize(new Dimension(250, 320));
        
        UpperPanel._showHidePanel = new ShowHidePanel(this._wwd);
        UpperPanel._logoPanel = new LoginLogo();
        UpperPanel._tabs.add("Welcome", UpperPanel._logoPanel);
        
     // Adding the tabs to the main panel.
        this.add(UpperPanel._tabs);
        this.setBorder(
                new CompoundBorder(BorderFactory.createEmptyBorder(),
    					new TitledBorder("Layers")));
        
        
    }
	
	public static void changePanels(){
		// Deleting login panel.
		UpperPanel._tabs.removeAll();
		// Adding the panels to the tabs.
		UpperPanel._tabs.add("Show/Hide objects", UpperPanel._showHidePanel);
	}
	
	public static void changeToLoginPanel(){
		// Remove data layers.
		UpperPanel.removeLayers();
		// Deleting login panel.
		UpperPanel._tabs.removeAll();
		// Add logo panel.
		UpperPanel._tabs.add("Welcome", UpperPanel._logoPanel);
	}
	
	public static void updateShowHidePanel(Map<String, AirspaceLayer> layers){
		((ShowHidePanel)UpperPanel._showHidePanel).updatePanel(layers);
	}
	
	public static void removeLayers(){
		((ShowHidePanel)UpperPanel._showHidePanel).removeLayers();
	}
	
}
